package cn.cpf.demo.starter;

import com.github.cosycode.common.ext.bean.Record;
import com.github.cosycode.common.util.common.BeanUtils;
import com.github.cosycode.dal.base.BaseDao;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * <b>Description : </b>
 * <p>
 * <b>created in </b> 2021/6/3
 *
 * @author CPF
 * @since 1.0
 **/
@Configuration
@ConditionalOnClass(BaseDao.class)
@EnableConfigurationProperties(MyBeanProperties.class)
public class MyBeanAutoConfiguration {

    @Bean
    public Record dataBean(MyBeanProperties redissonProperties) {
        Record dataBean = new Record();
        Map<String, Object> stringObjectMap = BeanUtils.pojoToStringObjectMap(redissonProperties);
        dataBean.putAll(stringObjectMap);
        return dataBean;
    }

}
